var events = require('events');
var emitter = new events.EventEmitter();

var listener1 = function(arg1, arg2) {
	console.log('listener1', arg1, arg2);
};

var listener2 = function(arg1, arg2) {
	console.log('listener2', arg1, arg2);
}

emitter.on('some', listener1);
emitter.once('some', listener2);

//emitter.removeListener('some', listener1);
emitter.removeAllListeners();

emitter.emit('some', "byvoid", 1991);
emitter.emit('some', "byvoid", 1992);

var http = require('http');
var querystring = require('querystring');
var util = require('util');
var url = require('url');

// http.createServer(function(req, res) {
// 		var post = '';
// 		req.on('data', function(chunk) {
// 			post += chunk;
// 		})

// 		req.on('end', function() {
// 			post = querystring.parse(post);
// 			res.end(util.inspect(post));
// 		})
// }).listen(3000);

var contents = querystring.stringify({
	name: 'byvoid',
	email: 'byvoid@byvoid.com',
	address: 'Zijing 2#, Tsinghua University',
});

var options = {
	host: 'www.byvoid.com',
	path: '/application/node/post.php',
	method: 'POST',
	headers: {
		'Content-Type': 'application/x-www-form-urlencoded',
		'Content-Length': contents.length
	}
};

var req = http.request(options, function(res) {
	res.setEncoding('utf-8');
	res.on('data', function(data) {
		console.log(data);
	});
});
req.write(contents);
req.end();